package servlets;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import actionForms.showContactValidationForm;
import domain.Contact;
import domain.IDAOContact;

public class showContactAction extends Action {

	public ActionForward execute(final ActionMapping pMapping, ActionForm pForm, final HttpServletRequest pRequest, final HttpServletResponse pResponse) {
		final showContactValidationForm lForm = (showContactValidationForm) pForm;
		ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(pRequest.getSession().getServletContext());
		IDAOContact dao = (IDAOContact)context.getBean("daoContact");	
		Contact contact = dao.getContact(lForm.getId());
		pRequest.setAttribute("contact", contact);
		return pMapping.findForward("showContactPage");
	}
}